feat(erc4626): accept zero-amount transactions instead of blocking (ENG-2372)#28
feat(erc4626): accept zero-amount transactions instead of blocking (ENG-2372)#28ajag408 wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthrough
ChangesZERO_AMOUNT Non-Blocking Flag
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/validators/evm/erc4626/erc4626.validator.ts (1)
234-254: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winStale comment contradicts new behavior.
The comment
// WRAP must send ETH valueno longer holds—zero-value wraps are now accepted and flagged asZERO_AMOUNT. Update it to avoid misleading future readers of this security validator.📝 Suggested comment update
- // WRAP must send ETH value + // WRAP ETH value (zero is accepted and flagged as ZERO_AMOUNT) const value = BigInt(tx.value ?? '0');🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/validators/evm/erc4626/erc4626.validator.ts` around lines 234 - 254, The inline comment above the wrap validation in erc4626.validator.ts is stale and contradicts the current ZERO_AMOUNT handling. Update the comment near the `value` check and `parseAndValidateCalldata` logic to reflect that zero-value wraps are accepted and reported as `ZERO_AMOUNT`, so future readers are not misled about the `deposit` flow in `ERC4626Validator`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/validators/evm/erc4626/erc4626.validator.ts`:
- Around line 234-254: The inline comment above the wrap validation in
erc4626.validator.ts is stale and contradicts the current ZERO_AMOUNT handling.
Update the comment near the `value` check and `parseAndValidateCalldata` logic
to reflect that zero-value wraps are accepted and reported as `ZERO_AMOUNT`, so
future readers are not misled about the `deposit` flow in `ERC4626Validator`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0109fc18-f89b-4f20-817c-e58026189c7f
📒 Files selected for processing (5)
package.jsonsrc/types/index.tssrc/validators/base.validator.tssrc/validators/evm/erc4626/erc4626.validator.test.tssrc/validators/evm/erc4626/erc4626.validator.ts
Summary by CodeRabbit
New Features
ZERO_AMOUNTflag.Bug Fixes
Chores
1.3.1.Shield now accepts zero-amount ERC-4626 transactions for recognized operation
patterns instead of rejecting them. Previously, a zero-amount
deposit/withdraw/redeem/unwrapwas hard-blocked ("… amount is zero"), which surfaced to clientsas the aggregate
"No matching operation pattern found"error — the root cause ofthe
redeem(0)false blocks seen in production soak (ENG-2372).Why this approach: we don't know why clients construct zero-amount txs
and don't want to break unknown flows. A zero-amount transaction is a no-op with no
visible security risk, so blocking it adds friction without protection. This
supersedes the earlier plan to reject
amount <= 0upstream in the monorepo with a412.
Scope is amount-only. Acceptance does not loosen any other invariant. A
zero-amount tx still must pass every existing check — whitelisted vault, correct
selector, no stray ETH value, and
owner/receivermust equal the user/expectedaddress. Only the
amount === 0short-circuit is removed.Telemetry. When an accepted transaction has a zero amount, the result now carries
a non-blocking
details.flags: ['ZERO_AMOUNT']signal so we can observe how often andwhy clients send these, and revisit a targeted block later if the data warrants it.
Changes
src/types/index.ts— add optionaldetails.flags?: string[]toValidationResult.src/validators/base.validator.ts—safe(flags?)can attach non-blocking flags.src/validators/evm/erc4626/erc4626.validator.ts— remove the zero-amount blocks invalidateSupply,validateWithdraw,validateUnwrap, andvalidateWrap; emitZERO_AMOUNTwhen the amount is zero. Receiver/owner checks are unchanged and still run.src/validators/evm/erc4626/erc4626.validator.test.ts— flip the four zero-amountreject-tests to assert acceptance + flag; add guard tests proving a zero-amount tx is
still blocked when the vault is not whitelisted, the receiver mismatches, or the owner
is not the user.
package.json—1.3.0→1.3.1(backward-compatible behavior change).approve(0)is unchanged — the approval validator already ignores the amount (USDTzero-allowance reset), and is the precedent this change follows.
QA Proof
Full Shield test suite green (10 suites, 5922 tests) with the flipped zero-amount
acceptance cases and the new amount-only guard tests:
What Needs to Be QA'd in Staging
SHIELD_MODE=MONITOR; send a zero-amountredeem(0)/withdraw(0)on a whitelisted ERC-4626 yield and confirm logs now show
Shield validation successful(wasShield validation failed/No matching operation pattern).ZERO_AMOUNTflag is present on the accepted result.owner/receiver(not the user)is still blocked.
(no
flagson the result).QA Team Notification